//引入二次封装的Axios
import request from '@/utils/request';

enum API {
	//获取spu数据
	getSpu = '/admin/product/',

	// 获取全部品牌的数据
	allTrademark = '/admin/product/baseTrademark/getTrademarkList',
	// 获取照片墙
	imageList = '/admin/product/spuImageList/',
	//获取某一个已有的SPU销售属性的接口
	saleAttrList = '/admin/product/spuSaleAttrList/',
	//获取项目整个销售属性--三个
	allSaleAttr = '/admin/product/baseSaleAttrList',

	//添加 spu
	addSpu = '/admin/product/saveSpuInfo',
	//修改spu
	updateSpu = '/admin/product/updateSpuInfo',
	//获取平台属性接口
	attr = '/admin/product/attrInfoList/',
	//添加sku
	addSku = '/admin/product/saveSkuInfo',
}

//获取spu数据api
export const reqHasSpu = (
	page: number,
	limit: number,
	category3Id: number | string
) => request.get(API.getSpu + `${page}/${limit}?category3Id=${category3Id}`);

// 获取全部品牌的数据  api
export const reqallTrademark = () => request.get(API.allTrademark);
//获取照片墙的数据
export const reqImageList = (spuId: any) =>
	request.get(API.imageList + `${spuId}`);
//获取某一个已有的SPU销售属性的接口
export const reqSaleAttrList = (spuId: any) =>
	request.get(API.saleAttrList + `${spuId}`);
//获取项目整个spu销售属性--三个
export const reqAllSaleAttr = () => request.get(API.allSaleAttr);

//添加和修改spu API post请求
export const reqAddOrUpdateSpu = (data: any) => {
	if (data.id) {
		return request.post(API.updateSpu, data);
	} else {
		return request.post(API.addSpu, data);
	}
};

//获取平台属性
export const reqAttr = (
	c1Id: number | string,
	c2Id: number | string,
	c3Id: number | string
) => request.get(API.attr + `${c1Id}/${c2Id}/${c3Id}`);

//添加sku
export const reqAddSku = (data: any) => request.post(API.addSku, data);
